home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Grafik / Misc / ImageEnginer / ARexx / Batch / Displace.ieb < prev    next >
Encoding:
Text File  |  1997-02-02  |  4.0 KB  |  163 lines

  1. /*
  2. ** $VER: Displace.ieb 1.3, IE Arexx script
  3. ** Image Engineer Batch Processing script
  4. ** Copyright © by Patrik M Nydensten
  5. ** 24/1 1997 Stockholm/Sweden
  6. **
  7. ** Displace pixels in image with alpha.
  8. */
  9.  
  10. options results
  11. signal on error
  12.  
  13. parse arg input command
  14. input = upper(strip(input))
  15. address 'IMAGEENGINEER'
  16.  
  17. select  /* Required batch script commands */
  18.   when input = 'INFO' then    return get_info()
  19.   when input = 'CONFIG' then  return get_config(command)
  20.   when input = 'PROCESS' then return process_image(command)
  21.   otherwise do
  22.     'REQUEST' '"Failure in call to batch script!"' '" Quit "'
  23.     return '<ERROR>'
  24.   end
  25. end
  26.  
  27. exit 0
  28.  
  29. /* Required "Get_info" procedure  ------------------------------------ */
  30. /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files       */
  31.  
  32. get_info:
  33.   back = 'OK A2'
  34. return back
  35.  
  36. /* Required "Get_config" procedure  ---------------------------------- */
  37.  
  38. get_config:
  39.   parse arg '"'command'"'
  40.  
  41.   Xoff=32 ; Yoff=32
  42.  
  43.   if command ~= '' then parse var command Xoff Yoff '#'CalcType '#'Hold '#'Scale
  44.  
  45.   'IE_TO_FRONT'
  46.  
  47.   form = 'FORM "Displace" " OK | Cancel "',
  48.   ' INTEGER,"X displacement",-128,127,'Xoff',SLIDER',
  49.   ' INTEGER,"Y displacement",-128,127,'Yoff',SLIDER'
  50.  
  51.   if command = '' then do
  52.     form = form||' CHECKBOX,"Hold image to make it stretch?",0',
  53.     ' CHECKBOX,"Stretch alpha to fit primary image?",1',
  54.     ' CYCLE,"Type:","Best|Fast",0'
  55.  
  56.     form
  57.     parse var result ok Xoff Yoff Hold Scale CalcType
  58.     if ok = 0 then return '<ERROR>'
  59.  
  60.     if CalcType=0 then CalcType='BEST'
  61.     else CalcType = 'FAST'
  62.   end
  63.   else do
  64.     form
  65.     parse var result ok Xoff Yoff
  66.     if ok = 0 then return '<ERROR>'
  67.  
  68.     Hold = 'none'
  69.     Scale = 'none'
  70.     CalcType = 'none'
  71.   end
  72.  
  73.   back = Xoff Yoff '#'CalcType '#'Hold '#'Scale
  74. return back
  75.  
  76. /* Required "Process_image" procedure  ------------------------------- */
  77.  
  78. process_image:
  79.   parse arg '"'src_image'"' '"'dst_image'"' '"'options'"' '"'alpha_image'"'
  80.   parse var options Xoff Yoff '#'CalcType '#'Hold '#'Scale
  81.  
  82.   'OPEN' '"'src_image'"' '24'
  83.   if (RC ~= 0) then do
  84.     'IE_TO_FRONT'
  85.     'REQUEST' '"Failed to load image:' d2c(10)||src_image'"' '" OK "'
  86.     return '<ERROR>'
  87.   end
  88.   else LoadImage = result
  89.  
  90.   'OPEN' '"'alpha_image'"' '8'
  91.   if (RC ~= 0) then do
  92.     'IE_TO_FRONT'
  93.     'REQUEST' '"Failed to load alpha:' d2c(10)||alpha_image'"' '" OK "'
  94.     return '<ERROR>'
  95.   end
  96.   else AlphaImage = result
  97.  
  98.   if strip(Scale) = 1 then do
  99.     'PROJECT_INFO' LoadImage 'WIDTH'
  100.     IW = RESULT
  101.     'PROJECT_INFO' LoadImage 'HEIGHT'
  102.     IH = RESULT
  103.     'PROJECT_INFO' AlphaImage 'WIDTH'
  104.     AW = RESULT
  105.     'PROJECT_INFO' AlphaImage 'HEIGHT'
  106.     AH = RESULT
  107.  
  108.     if (IW=AW)&(IH=AH) then leave
  109.  
  110.     'SCALE' AlphaImage IW IH 'BEST'
  111.     NewAlphaImage = result
  112.     'CLOSE' AlphaImage
  113.     AlphaImage = NewAlphaImage
  114.   end
  115.  
  116.   if strip(Hold) = 1 then do
  117.     'COLOUR_FILTER' AlphaImage 'INTENSITY' '128' '0'
  118.     NewAlphaImage = result
  119.     'CLOSE' AlphaImage
  120.     AlphaImage = NewAlphaImage
  121.   end
  122.  
  123.   'MARK' LoadImage 'PRIMARY'
  124.   'MARK' AlphaImage 'ALPHA'
  125.  
  126.   'DISPLACE' Xoff Yoff CalcType
  127.   OutputImage = result
  128.   'CLOSE' LoadImage
  129.   'CLOSE' AlphaImage
  130.  
  131.   if getclip('cfg_save_frmt')='' then setclip('cfg_save_frmt','ILBM CmpByteRun1')
  132.   'SAVE_DATA' OutputImage '"'dst_image'"' '"'getclip('cfg_save_frmt')'"'
  133.   if (RC ~= 0) then do
  134.     'IE_TO_FRONT'
  135.     'REQUEST' '"Failed to save image:' d2c(10)||dst_image'"' '" OK "'
  136.     return '<ERROR>'
  137.   end
  138.   'CLOSE' OutputImage
  139.  
  140.   back = 'OK'
  141. return back
  142.  
  143. /* Internal procedures  ---------------------------------------------- */
  144.  
  145. /*******************************************************************/
  146. /* This is where control goes when an error code is returned by IE */
  147. /* It puts up a message saying what happened and on which line     */
  148. /*******************************************************************/
  149.  
  150. error:
  151. if RC=5 then do
  152.     IE_TO_FRONT
  153.     LAST_ERROR
  154.     'REQUEST "'||RESULT||'"'
  155. end
  156. else do
  157.     IE_TO_FRONT
  158.     LAST_ERROR
  159.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  160. end
  161.  
  162. return '<ERROR>'
  163.